﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/HomeSite.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript"></script>

    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="100%" 
        CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" 
        GroupBoxCaptionOffsetY="-28px" 
        SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css">
        <ContentPaddings Padding="14px" />
        <PanelCollection>
<dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
<% using (Html.BeginForm())
   { %>
    <%: Html.ValidationSummary(true)%>

    <% 
       TimeTableManagement.QLSVContext db = new TimeTableManagement.QLSVContext();
       var model = db.Tb_Config.Where(g => g.option.Equals("inforschool")).ToList();
       foreach (TimeTableManagement.Entities.Tb_Config insch in model)
       {
    %>
        <div class="editor-label">
            <%: insch.displayword %>
        </div>
        <% if (!insch.keyword.Equals("logo")) 
           { %>
        <div class="editor-field">
            <input class="text-box single-line valid inforitem" size=80 name="<%: insch.id %>" id="<%: insch.id %>" 
                keyword="<%: insch.keyword %>" type="text" value="<%: insch.value %>">
                
        </div>
        <% }
           else
           { %>
           <div class="editor-field">
            <img alt="" class="inforitem" id="<%: insch.id %>" value="<%: insch.value %>" 
                keyword="<%: insch.keyword %>" src="<%: insch.value %>" />
            Change Logo
           </div>
        <% } %>
    
    <% } %>
    
<input id="inforschool" name="inforschool" type="hidden" />
<%--Tao chuoi json cho inforschool theo cau truc
[{"id":id,"keyword":"tu khoa","value":"gia tri"},{"id":id,"keyword":"tu khoa","value":"gia tri"}]--%>
    <p>
        <input type="submit" value="Save" onclick="return updatejson()"/>
    </p>
<% } %>
</dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<script>
    function updatejson() {
        $json = "";
        $items = document.getElementsByClassName('inforitem');
        for ($i = 0; $i < $items.length; $i++) {
            $item = $items.item($i);
            $id = $item.id;
            $keyword = $item.getAttribute('keyword');
            $value = $item.value;
            if (typeof $value == "undefined") {
                $value = $item.getAttribute('value');
            }
            //$value = $value.replace(/^\s+|\s+$/g, "");
            $json = $json + ',{"id":' + $id + ',"key":"' + $keyword + '","value":"' + $value + '"}';
        }
        $json = '[' + $json.substr(1) + ']';
        document.getElementById('inforschool').value = $json;
        return true;
    }
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="leftmenu" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="menuright" runat="server">
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>